//
//  AppDelegate.m
//  LittleFairyPoet
//
//  Created by rimi on 15/9/7.
//  Copyright (c) 2015年 周林. All rights reserved.
//

#import "AppDelegate.h"
#import "ZLTabViewController.h"
#import "WPAlerView.h"
#import "TopViewModel.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.window makeKeyAndVisible];
    [NSThread sleepForTimeInterval:1.0];
    [[UIApplication sharedApplication] setStatusBarHidden:TRUE];
    if([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
        UIUserNotificationSettings *noteSetting =[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound
                                                                                   categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:noteSetting];
    }
    return YES;
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    [WPAlerView showAlertViewWithMsg:notification.alertBody];
    [TopViewModel cancelNotification];
}
#pragma mark - getter
- (UIWindow *)window
{
    if (!_window) {
        _window = ({
            UIWindow * window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[ZLTabViewController new]];
            window.rootViewController = nav;
            window;
        });
    }
    return _window;
}

@end
